﻿using System.Linq;
using System.Web.Mvc;
using time;
using time;
using myframework._99_热身.time._2011_10_24_scm;
//using PagedList;

namespace MvcApplication1.Controllers
{
    public class ClothesController : Controller
    {
        //
        // GET: /Clothes/

        //public ActionResult Index(string sortOrder, string searchString, int? page)
        //{
        //    var lc = common.GetClothes(sortOrder, searchString);

        //    const int pageSize = 10;
        //    var listPaged = lc.ToPagedList(page.HasValue ? page.Value - 1 : 0, pageSize);

        //    return View(listPaged);
        //}

        //
        // GET: /Clothes/Details/5

        public ActionResult Details(string id)
        {
            //Clothes clothes = GetClothes(id);
            Clothes clothes = null;

            return View(clothes);
        }

        //
        // GET: /Clothes/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Clothes/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Clothes/Edit/5

        public ActionResult Edit(string id)
        {
            //Clothes clothes = time.common.GetClothes(id.ToString());
            Clothes clothes = null;
            return View(clothes);
        }

        //
        // POST: /Clothes/Edit/5

        [HttpPost]
        public ActionResult Edit(string id, FormCollection collection)
        {
            DataClasses1DataContext dc = new DataClasses1DataContext();
            var album = dc.Clothes.Single(z => z.ClothesCode == id);
            try
            {
                if (TryUpdateModel(album))
                {
                    dc.SubmitChanges();
                    return RedirectToAction("Index");
                }
                else
                {
                    return RedirectToAction("Index");
                }
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Clothes/Delete/5

        public ActionResult Delete(int id)
        {
            return View();
        }

        //
        // POST: /Clothes/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}